#!/usr/bin/env python

def get_gfse(site,invar):
    import cPickle
    gfse_dict = cPickle.load(open('../gfs_ensemble_mos/%s_gfse_performance.pickle' % (site.upper()),'r'))
    keysort = gfse_dict.keys()
    keysort.sort()
    out_bma = []
    out_low50 = []
    out_high50 = []
    out_low90 = []
    out_high90 = []
    for date in keysort:
        if invar in ['highs','lows']:
            out_bma.append(gfse_dict[date][invar + '_bma'])
            out_low50.append(gfse_dict[date][invar + '_low50'])
            out_high50.append(gfse_dict[date][invar + '_high50'])
            out_low90.append(gfse_dict[date][invar + '_low90'])
            out_high90.append(gfse_dict[date][invar + '_high90'])
        else:
            out_bma.append(0.0)
            out_low50.append(0.0)
            out_high50.append(0.0)
            out_low90.append(0.0)
            out_high90.append(0.0)
    #print "OUT_DATES", keysort
    #print "OUT_HIGH90", out_high90
    # TEMPORARY
    if invar == 'highs' and site.lower() == 'ksea':
        out_high90[1] = 90.0
    return keysort,out_bma,out_low50,out_high50,out_low90,out_high90

